package com.dc.adaptor.persistance;

import org.pentaho.di.core.database.Database;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.core.row.ValueMeta;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.repository.Repository;

import com.dc.adaptor.persistance.bean.NxdsFcjyRequest;

public class NxdsFcjyDbHandler extends DatabaseHandler {
    public NxdsFcjyDbHandler(Repository repository) {
        super(repository);
    }

    public NxdsFcjyDbHandler() {
        super();
    }

    public void insertFcjy(final String bwlx, final NxdsFcjyRequest obj) throws Exception {
        doInConnection(new ConnectionCallback<String>() {
            @Override
            public String doInConnection(Database db) throws Exception {
                RowMetaInterface fcjyMeta = new RowMeta();
                fcjyMeta.addValueMeta(new ValueMeta("XH", ValueMetaInterface.TYPE_STRING, 32, 0));
                fcjyMeta.addValueMeta(new ValueMeta("TRAN_ID", ValueMetaInterface.TYPE_STRING, 30, 0));
                fcjyMeta.addValueMeta(new ValueMeta("CHANNEL_ID", ValueMetaInterface.TYPE_STRING, 30, 0));
                fcjyMeta.addValueMeta(new ValueMeta("TRAN_SEQ", ValueMetaInterface.TYPE_STRING, 32, 0));
                fcjyMeta.addValueMeta(new ValueMeta("TRAN_DATE", ValueMetaInterface.TYPE_STRING, 8, 0));
                fcjyMeta.addValueMeta(new ValueMeta("TRAN_TIME", ValueMetaInterface.TYPE_STRING, 15, 0));
                fcjyMeta.addValueMeta(new ValueMeta("RTN_CODE", ValueMetaInterface.TYPE_STRING, 10, 0));
                fcjyMeta.addValueMeta(new ValueMeta("BODY", ValueMetaInterface.TYPE_STRING, 4000, 0));
                fcjyMeta.addValueMeta(new ValueMeta("SJRY", ValueMetaInterface.TYPE_STRING, 15, 0));
                fcjyMeta.addValueMeta(new ValueMeta("SJJG", ValueMetaInterface.TYPE_STRING, 15, 0));
                fcjyMeta.addValueMeta(new ValueMeta("BWLX", ValueMetaInterface.TYPE_STRING, 15, 0));
                fcjyMeta.addValueMeta(new ValueMeta("RESULT", ValueMetaInterface.TYPE_STRING, 4000, 0));

                Object[] rowData = new Object[] { obj.getXh(), obj.getTran_id(), obj.getChannel_id(), obj.getTran_seq(), obj.getTran_date(), obj.getTran_time(), obj.getRtn_code(), obj.getBody(),
                        obj.getSjry(), obj.getSjjg(), bwlx, obj.getResult() };

                insert("WBJH_NXDS_FCJY_LOG", fcjyMeta, rowData);
                return null;
            }
        });
    }
}
